package com.javafactroy.kunlong.bip.icp.factory;

import com.javafactroy.kunlong.bip.icp.common.consts.IMsgType;
import com.javafactroy.kunlong.bip.icp.factory.iface.IMessageHandler;

import com.javafactroy.kunlong.bip.icp.message.base.iface.IMessage;
import com.javafactroy.kunlong.bip.icp.message.dxp.base.DxpMsgResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class AppMessageHandler implements IMessageHandler {

    @Override
    public DxpMsgResp execute(IMessage message) {
        log.info("server AppMessageHandler execute...");

        DxpMsgResp resp= DxpMsgResp.buildMessage();
        resp.getHeader().setMsgId(Integer.valueOf(message.getMessageId()));
        return resp;
    }

    public static void register() {
        System.out.println("AppMessageHandler server register ...");
        AppMessageFactory.getInst().registerHandler(String.valueOf(IMsgType.MsgType_APP_DATA), new AppMessageHandler());

    }

    static {
        register();
    }
}